import styles from '../css/SearchResult.module.css'
import { DeleteOutline } from 'antd-mobile-icons'
import { Dialog } from 'antd-mobile'
import {searchHistory} from '../../../store/slice/ticket'
import { useDispatch } from 'react-redux'
function SearchResult(props) {

  const dispatch=useDispatch()
  return (
    <div className={styles.box}>
      <div className={styles.title}>
        <span>搜索历史</span>
        <DeleteOutline
          fontSize={20}
          onClick={() =>
            Dialog.confirm({
              content: '你确认删除搜索历史吗？',
              onConfirm: () => props.clear()
            })
          }
        />
      </div>
      <ul className={styles.list}>
        {props.list.map((item, i) => (
          <li
            key={i}
            onClick={() => {
             dispatch(searchHistory(item)),
              props.myfn(item)}
              }
          >
            {item}
          </li>
        ))}
      </ul>
    </div>
  )
}

export default SearchResult
